﻿//文件写入类
//参数
//[1]TargetDir:文件目标路径，缺省为程序所在路径
//[2]FileName:文件名称，缺省为tempFile.txt
//[3]Content:欲写入的内容

//import CRIAP.Silly.*;
class CRIAP.LocalControl.FileControl
{
	private var _CurrentDir:String = new String("NULL");
	private var _Listener:Object = new Object();
	private var _TargetDir:String = new String();
	private var _Content:String = new String("This File Created by CRIAP.LocalControl.FileControl");
	public function FileControl(Listener:Object)
	{
		_Listener = Listener;
	}
	public function SaveFile(TargetDir:String,FileName:String,Content:String,CallBack)
	{
		//回调指令
		_Listener.addProperty("SaveFile", getLink, CallBack);
		
		var xmlDoc:XML = new XML();
		var xmlNode:XMLNode = xmlDoc.createElement("TargetDir");
		
		//保存内容
		if(Content)
		{
			xmlNode.attributes.Content 		= 	Content;
		}else
		{
			xmlNode.attributes.Content 		= 	'---------This File Created by CRIAP--------------';
		}
		
		//保存的文件名
		if(FileName)
		{
			xmlNode.attributes.FileName		=	FileName;
		}else
		{
			xmlNode.attributes.FileName		=	'tempFile.log';
		}
		
		//保存的目标路径
		if(TargetDir)
		{
			xmlNode.attributes.TargetDir	=	TargetDir;
			
		}else
		{
			xmlNode.attributes.TargetDir	=	'CurrentDir';
		}
		
		xmlDoc.appendChild(xmlNode);
		
		//拼合一个XML文档并传给客户端
		var strXML:String = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
		strXML += "<DataRecord>"+xmlDoc.toString()+"</DataRecord>";
		fscommand("SaveFile",strXML);
	}
	public function getLink(value)
	{
		
	}
}